<form id="handlePermissionAllotForm">
    <input type="hidden" name="objType" value="${objType}">
    <input type="hidden" name="objId" value="${objId}">
    <input type="hidden" name="menuPermissionId" value="${menuPermissionId}">
    <div class="row" style="max-height:586px; overflow:auto;margin-right:0px;">
        <#list nowMenuAllHandlePermission as mahp>
            <div class="col-lg-6 col-sm-6 col-xs-6">
                <div class="checkbox">
                    <label>
                        <#assign isHave="1"/>
                        <#list alreadyHaveHandlePremissions as ahhp>
                            <#if ahhp.defaultHandlePermissionId==mahp.id>
                                <#assign isHave="2" />
                            </#if>
                        </#list>
                        <#if isHave=="2">
                            <input type="checkbox" name="handlePermissionId" value="${mahp.id}"
                                   ${mahp.isForbidden?string("disabled","")} class="inverted" checked>
                            <#else>
                                <input type="checkbox" name="handlePermissionId" value="${mahp.id}" class="inverted"
                                       ${mahp.isForbidden?string("disabled","")}>
                        </#if>
                        <span class="text">${mahp.name}</span>
                    </label>
                </div>
            </div>
        </#list>
    </div>
    <div class="col-lg-12 bordered-top-3 bordered-palegreen">
        <div class="col-lg-5">
            <a class="btn btn-yellow btn-xs btn-mini margin-top-10" onclick="checkAllHp()">全选</a>
            <a class="btn btn-magenta btn-xs btn-mini margin-top-10" onclick="unCheckAllHp()">反选</a>
            <a class="btn btn-azure btn-xs btn-mini margin-top-10" onclick="checkOtherAllHp()">全不选</a>
        </div>
        <div class="col-lg-7 text-align-right">
            <a class="btn btn-success margin-top-10" onclick="resetHp()">重置</a>
            <a class="btn btn-danger margin-top-10" onclick="saveHandlePermissionAllot()">保存</a>
        </div>
    </div>
</form>
<script type="text/javascript">
    /**
     * 全选
     */
    function checkAllHp() {
        $("#handlePermissionAllotForm :checkbox:enabled").map(function (idnex, chk) {
            chk.checked = true;
        });
    }

    /**
     * 反选
     */
    function unCheckAllHp() {
        $("#handlePermissionAllotForm :checkbox:enabled").map(function (idnex, chk) {
            chk.checked = !chk.checked;
        });
    }

    /**
     * 全不选
     */
    function checkOtherAllHp() {
        $("#handlePermissionAllotForm :checkbox:enabled").map(function (idnex, chk) {
            chk.checked = false;
        });
    }

    /**
     * 重置
     */
    function resetHp() {

    }

    /**
     * 保存
     */
    function saveHandlePermissionAllot() {
        var params = $("#handlePermissionAllotForm").serializeArray();
        ajaxRequest("permissionSetting/saveHandlePermissionAllot.do", params, function (result) {
            if (result.resCode == 200) {
                alert("保存成功!");
            } else {
                logger.error("保存失败，请稍后再试!")
            }
        }, function () {
            logger.error("保存失败，请稍后再试!")
        }, "POST", "JSON")
    }
</script>